@extends('admin.layouts.app')
@section('content')

                        <!-- Page-Title -->
                        <div class="row">
                            <div class="col-sm-12">
                                <h4 class="page-title">车辆管理</h4>
                                <ol class="breadcrumb">
                                    <li><a href="#">系统</a></li>
                                    
                                    <li class="active">车辆列表</li>
                                </ol>
                            </div>
                        </div>
                        
                        <div class="row">
                        	<div class="col-lg-12">
                        		<div class="card-box">
                        			<div class="row">
			                        	<div class="col-sm-8">
			                        		<form role="form" id="form1">
			                                    <div class="form-group contact-search m-b-30 col-md-8">
			                                    	<input type="text" id="search" class="form-control" placeholder="Search..." name="keyword" value="{{array_get($where,'keyword')}}">
			                                        
			                                    </div>
                                          <div class="col-md-4">
                                            <button type="button" class="btn btn-white" id="srcBtn"><i class="fa fa-search"></i></button>
                                          </div> <!-- form-group -->
			                                </form>
			                        	</div>
                                <div class="col-sm-2">
                    <button  class="btn btn-success btn-sm" id="exportBtn" type="button"><i class="md  md-file-download">导出</i></button>
                  </div>
			                        	<div class="col-sm-2">
			                        		

                                  <a href="{{url('zadmin/cars/create')}}" class="btn btn-primary btn-md waves-effect waves-light m-b-30" ><i class="md md-add"></i>添加</a>
			                        	</div>
			                        </div>

                              @if(session('rs'))
                              <div class="alert alert-{{session('rs')['status']}}">
                                {{ session('rs')['msg'] }}
                              </div>
                              @endif
			                        
                        			<div class="table-responsive">
                                        <table class="table table-hover">
                                        	<thead>
												<tr>
													<th style="min-width: 35px;">
													 <input type="checkbox" id="checkAll">全选
                                                        
													</th>
                          <th>所属客户</th>
													<th>车牌号</th>
													 <th>车架号/VIN号</th>
                          <th>车型车系</th>
                          <th>发动机号</th> 
                          <th>车辆类型</th>
                         
													<th style="width: 200px;">操作</th>
												</tr>
											</thead>
											
                                            <tbody>

                                            @foreach($list as $v)
                                                <tr>
                                                    <td>
                                                        <input type="checkbox" class="ids" name="ids" value="{{$v->id}}">
                                                        
                                                      
                                                    </td>
                                                <td>{{object_get($v,'client.name')}}</td>    
                                                    <td>
                                                      {{$v->car_num}}
                                                    </td>
                                                     <td>
                                                      {{$v->vin}}
                                                    </td>
                                                    <td>{{object_get($v,'brand.name')}} {{object_get($v,'serie.name')}} {{object_get($v,'model.name')}}</td>
                                                    
                                                    <td>{{$v->engine_num}}</td>
                                                    <td>{{object_get($v,'type.name')}}</td>
                                                
                                                    
                                                   
                                                    <td>
                                                    	<a href="{{url('zadmin/cars/'.$v->id.'/edit')}}" ><i class="md md-edit"></i>编辑</a>
                                                    	<a href="{{url('zadmin/cars',$v->id)}}" data-method="delete" 
  data-token="{{csrf_token()}}" data-confirm="确定删除吗?"><i class="md md-close"></i>删除</a>
                                                    </td>
                                                </tr>
                                            @endforeach    
                                                
                                               
                                               
                                                
                                               
                                                
                                            
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="row">
                                      <button type="button" class="btn btn-sm  btn-danger btn-batchdel" type="button" >批量删除</button>
                                     
                                    </div> 
                                     {{ $list->links() }}
                        		</div>
                                
                            </div> <!-- end col -->

                            
                        </div>
@endsection
                        
                        
                        

                  
            
    @section('modal')        
        <!-- Modal -->
      <div id="custom-modal" class="modal-demo">
          <button type="button" class="close" onclick="Custombox.close();">
              <span>&times;</span><span class="sr-only">Close</span>
          </button>
          <h4 class="custom-modal-title">添加车辆</h4>
          <div class="custom-modal-text text-left">
              <form class="form-horizontal" role="form" action="{{url('zadmin/worklog')}}" method="post" enctype="multipart/form-data">                                    
                                              <div class="form-group">
                                                  <label class="col-md-2 control-label">服务图片</label>
                                                  <div class="col-md-10">
                                                      <input type="file" class="form-control" name="pic" value="" required="">
                                                  </div>
                                              </div>
                                              <div class="form-group">
                                                  <label class="col-md-2 control-label">服务日期</label>
                                                  <div class="col-md-10">
                                                      <input type="text" class="form-control" name="logtime" value="{{date('Y-m-d')}}" required="">
                                                  </div>
                                              </div>
                                              
                                                                                                                    
                                             

                                              <div class="form-group text-center">
                                                  
                                                  <button type="submit" class="btn btn-info waves-effect waves-light">保存</button>
                                              </div>
                                              
                                              
                             {{csrf_field()}}
                                          </form>
          </div>
      </div>
    @endsection    

    @section('js')
    <script type="text/javascript">
       $('#srcBtn').on('click',function(){
      var url = "{{url('zadmin/services')}}";
      $('#form1').attr('action',url).submit(); 
    });

    $('#exportBtn').on('click',function(){
      var url = "{{url('zadmin/cars/export')}}";
      $('#form1').attr('action',url).submit(); 
    });

    $('#checkAll').click(function () {    
      $('input:checkbox').prop('checked', this.checked);    
    });

    $('.btn-batchdel').on('click',function(){
      var ids = [];
      $('input[name="ids"]:checked').each(function() {
         ids.push(this.value);
      });
      
      if(ids==''){
        alert('请选择要删除的数据');return;
      }
      var data = {};
      data.ids = ids;     
     
      data._token= "{{csrf_token()}}";
      var url = "{{url('zadmin/cars/batch-del')}}"
      $.post(url,data,function(rs){
        if(rs.status==true) {
          window.location.reload(true);
        } else {
          alert('操作失败');
        }
      })
    })
    </script>
    @endsection    
       

           



    
        
    
